if (i == 0)
{
- _gtk_css_parser_error (parser, "Expected a number");
+ gtk_css_parser_error_syntax (parser, "Expected a number");
_gtk_css_value_unref (result);
return NULL;
}
gtk_css_calc_value_parse_value (GtkCssParser *parser,
GtkCssNumberParseFlags flags)
{
- if (gtk_css_parser_has_function (parser, "calc"))
- {
- _gtk_css_parser_error (parser, "Nested calc() expressions are not allowed.");
- return NULL;
- }
-
if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_OPEN_PARENS))
{
GtkCssValue *result;
}
if (!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF))
- _gtk_css_parser_error (parser, "Expected closing ')' in calc() subterm");
+ gtk_css_parser_error_syntax (parser, "Expected closing ')' in calc() subterm");
gtk_css_parser_end_block (parser);
if (is_number (result) && !(flags & GTK_CSS_PARSE_NUMBER))
{
- _gtk_css_parser_error (parser, "calc() product term has no units");
+ gtk_css_parser_error_syntax (parser, "calc() product term has no units");
goto fail;
}
if (!gtk_css_parser_has_function (parser, "calc"))
{
- _gtk_css_parser_error (parser, "Expected 'calc('");
+ gtk_css_parser_error_syntax (parser, "Expected 'calc('");
return NULL;
}
{
if (values[arg] < 0 || values[arg] > 1.0)
{
- _gtk_css_parser_error (parser, "value %g out of range. Must be from 0.0 to 1.0", values[arg]);
+ gtk_css_parser_error_value (parser, "value %g out of range. Must be from 0.0 to 1.0", values[arg]);
return 0;
}
}
}
else if (data->n_steps < 1)
{
- _gtk_css_parser_error (parser, "Number of steps must be > 0");
+ gtk_css_parser_error_value (parser, "Number of steps must be > 0");
return 0;
}
return 1;
data->start = FALSE;
else
{
- _gtk_css_parser_error (parser, "Only allowed values are 'start' and 'end'");
+ gtk_css_parser_error_syntax (parser, "Only allowed values are 'start' and 'end'");
return 0;
}
return 1;
}
}
- _gtk_css_parser_error (parser, "Unknown value");
+ gtk_css_parser_error_syntax (parser, "Expected a valid ease value");
return NULL;
}
if (array->len == 0)
{
- _gtk_css_parser_error (parser, "Expected a filter");
+ gtk_css_parser_error_syntax (parser, "Expected a filter");
goto fail;
}
if (!is_valid_opentype_tag (name))
{
- _gtk_css_parser_error (parser, "Not a valid OpenType tag.");
+ gtk_css_parser_error_value (parser, "Not a valid OpenType tag.");
g_free (name);
_gtk_css_value_unref (result);
return NULL;
if (!is_valid_opentype_tag (name))
{
- _gtk_css_parser_error (parser, "Not a valid OpenType tag.");
+ gtk_css_parser_error_value (parser, "Not a valid OpenType tag.");
g_free (name);
_gtk_css_value_unref (result);
return NULL;
image_type = gtk_css_image_get_parser_type (parser);
if (image_type == G_TYPE_INVALID)
{
- _gtk_css_parser_error (parser, "Not a valid image");
+ gtk_css_parser_error_syntax (parser, "Not a valid image");
return NULL;
}
{
if (!gtk_css_parser_try_ident (parser, "builtin"))
{
- _gtk_css_parser_error (parser, "Expected 'builtin'");
+ gtk_css_parser_error_syntax (parser, "Expected 'builtin'");
return FALSE;
}
if (*progress > 1.0)
{
- _gtk_css_parser_error (parser, "Percentages over 100%% are not allowed");
+ gtk_css_parser_error_value (parser, "Percentages over 100%% are not allowed");
return FALSE;
}
{
if (!gtk_css_parser_has_function (parser, "cross-fade"))
{
- _gtk_css_parser_error (parser, "Expected 'cross-fade('");
+ gtk_css_parser_error_syntax (parser, "Expected 'cross-fade('");
return FALSE;
}
if (data->color != NULL)
{
- _gtk_css_parser_error (parser, "The color must be the last parameter");
+ gtk_css_parser_error_syntax (parser, "The color must be the last parameter");
return 0;
}
else if (_gtk_css_image_can_parse (parser))
if (!gtk_css_parser_has_function (parser, "image"))
{
- _gtk_css_parser_error (parser, "Expected 'image('");
+ gtk_css_parser_error_syntax (parser, "Expected 'image('");
return FALSE;
}
{
if (!gtk_css_parser_has_function (parser, "-gtk-icontheme"))
{
- _gtk_css_parser_error (parser, "Expected '-gtk-icontheme('");
+ gtk_css_parser_error_syntax (parser, "Expected '-gtk-icontheme('");
return FALSE;
}
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
- _gtk_css_parser_error (parser, "Expected 'top', 'bottom' or comma");
+ gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_LEFT);
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
- _gtk_css_parser_error (parser, "Expected 'top', 'bottom' or comma");
+ gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_RIGHT);
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
- _gtk_css_parser_error (parser, "Expected 'left', 'right' or comma");
+ gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_TOP);
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
- _gtk_css_parser_error (parser, "Expected 'left', 'right' or comma");
+ gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_BOTTOM);
if (linear->side == 0)
{
- _gtk_css_parser_error (parser, "Expected side that gradient should go to");
+ gtk_css_parser_error_syntax (parser, "Expected side that gradient should go to");
return 0;
}
self->repeating = FALSE;
else
{
- _gtk_css_parser_error (parser, "Not a linear gradient");
+ gtk_css_parser_error_syntax (parser, "Not a linear gradient");
return FALSE;
}
{
if (radial->sizes[0] && radial->sizes[1])
{
- _gtk_css_parser_error (parser, "Circular gradient can only have one size");
+ gtk_css_parser_error_syntax (parser, "Circular gradient can only have one size");
return 0;
}
if (radial->sizes[0] && gtk_css_number_value_has_percent (radial->sizes[0]))
{
- _gtk_css_parser_error (parser, "Circular gradient cannot have percentage as size");
+ gtk_css_parser_error_syntax (parser, "Circular gradient cannot have percentage as size");
return 0;
}
}
self->repeating = FALSE;
else
{
- _gtk_css_parser_error (parser, "Not a radial gradient");
+ gtk_css_parser_error_syntax (parser, "Not a radial gradient");
return FALSE;
}
case 1:
self->palette = gtk_css_palette_value_parse (parser);
if (self->palette == NULL)
- {
- _gtk_css_parser_error (parser, "A palette is required here");
- return 0;
- }
+ return 0;
return 1;
default:
{
if (!gtk_css_parser_has_function (parser, "-gtk-recolor"))
{
- _gtk_css_parser_error (parser, "Expected '-gtk-recolor('");
+ gtk_css_parser_error_syntax (parser, "Expected '-gtk-recolor('");
return FALSE;
}
if (!gtk_css_parser_has_function (parser, "-gtk-scaled"))
{
- _gtk_css_parser_error (parser, "Expected '-gtk-scaled('");
+ gtk_css_parser_error_syntax (parser, "Expected '-gtk-scaled('");
return FALSE;
}
property = _gtk_style_property_lookup (name);
if (property == NULL)
{
- /* should be GTK_CSS_PARSER_ERROR_NAME */
- _gtk_css_parser_error (parser, "No property named '%s'", name);
+ gtk_css_parser_error_value (parser, "No property named '%s'", name);
g_free (name);
return FALSE;
}
if (!gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COLON))
{
- _gtk_css_parser_error (parser, "Expected a ':'");
+ gtk_css_parser_error_syntax (parser, "Expected a ':'");
return FALSE;
}
if (!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF))
{
- _gtk_css_parser_error (parser, "Junk at end of value");
+ gtk_css_parser_error_syntax (parser, "Junk at end of value");
_gtk_css_value_unref (value);
return FALSE;
}
}
if (!animatable)
- _gtk_css_parser_error (parser, "shorthand '%s' cannot be animated", _gtk_style_property_get_name (property));
+ gtk_css_parser_error_value (parser, "shorthand '%s' cannot be animated", _gtk_style_property_get_name (property));
}
else if (GTK_IS_CSS_STYLE_PROPERTY (property))
{
if (!keyframes_set_value (keyframes, k, GTK_CSS_STYLE_PROPERTY (property), value))
- _gtk_css_parser_error (parser, "Cannot animate property '%s'", _gtk_style_property_get_name (property));
+ gtk_css_parser_error_value (parser, "Cannot animate property '%s'", _gtk_style_property_get_name (property));
}
else
{
#include "gtkcssparserprivate.h"
-void
-_gtk_css_parser_error (GtkCssParser *parser,
- const char *format,
- ...)
-{
- GtkCssLocation location;
- va_list args;
- GError *error;
-
- gtk_css_parser_get_location (parser, &location);
- va_start (args, format);
- error = g_error_new_valist (GTK_CSS_PARSER_ERROR,
- GTK_CSS_PARSER_ERROR_FAILED,
- format, args);
- gtk_css_parser_emit_error (parser, &location, &location, error);
- g_error_free (error);
- va_end (args);
-}
-
void
_gtk_css_print_string (GString *str,
const char *string)
G_BEGIN_DECLS
-void _gtk_css_parser_error (GtkCssParser *parser,
- const char *format,
- ...) G_GNUC_PRINTF (2, 3);
-
/* XXX: Find better place to put it? */
void _gtk_css_print_string (GString *str,
const char *string);
else
{
if (!try)
- _gtk_css_parser_error (parser, "Unrecognized position value");
+ gtk_css_parser_error_syntax (parser, "Unrecognized position value");
return NULL;
}
}
if (missing != &y)
{
if (!try)
- _gtk_css_parser_error (parser, "Invalid combination of values");
+ gtk_css_parser_error_syntax (parser, "Invalid combination of values");
_gtk_css_value_unref (y);
return NULL;
}
(!names[first].horizontal && !names[second].horizontal))
{
if (!try)
- _gtk_css_parser_error (parser, "Invalid combination of values");
+ gtk_css_parser_error_syntax (parser, "Invalid combination of values");
_gtk_css_value_unref (x);
_gtk_css_value_unref (y);
return NULL;
if (i == 0)
{
- _gtk_css_parser_error (parser, "Expected a length");
+ gtk_css_parser_error_syntax (parser, "Expected a length");
return FALSE;
}
if (i == 0)
{
- _gtk_css_parser_error (parser, "Expected a number");
+ gtk_css_parser_error_syntax (parser, "Expected a number");
goto fail;
}
if (i == 0)
{
- _gtk_css_parser_error (parser, "Expected a number");
+ gtk_css_parser_error_syntax (parser, "Expected a number");
goto fail;
}
if (i == 0)
{
- _gtk_css_parser_error (parser, "Expected a border style");
+ gtk_css_parser_error_syntax (parser, "Expected a border style");
return FALSE;
}
if (_gtk_css_number_value_get (values[3], 100) < 1 ||
_gtk_css_number_value_get (values[3], 100) > 1000)
{
- _gtk_css_parser_error (parser, "Font weight values must be between 1 and 1000");
+ gtk_css_parser_error_value (parser, "Font weight values must be between 1 and 1000");
g_clear_pointer (&values[3], gtk_css_value_unref);
+ return FALSE;
}
- return FALSE;
}
parsed_one = parsed_one || values[3] != NULL;
}
while (parsed_one && !value_is_done_parsing (parser));
values[5] = gtk_css_font_size_value_parse (parser);
+ if (values[5] == NULL)
+ return FALSE;
have_font_size:
values[0] = gtk_css_font_family_value_parse (parser);
+ if (values[0] == NULL)
+ return FALSE;
- return values[0] != NULL && values[5] != NULL;
+ return TRUE;
}
static gboolean
parsed_ligature = _gtk_css_font_variant_ligature_try_parse_one (parser, ligatures);
if (parsed_ligature == 0 && ligatures != 0)
{
- _gtk_css_parser_error (parser, "Invalid combination of ligature values");
+ gtk_css_parser_error_value (parser, "Invalid combination of ligature values");
return FALSE;
}
if (parsed_ligature == GTK_CSS_FONT_VARIANT_LIGATURE_NORMAL ||
parsed_ligature == GTK_CSS_FONT_VARIANT_LIGATURE_NONE)
{
- _gtk_css_parser_error (parser, "Unexpected ligature value");
+ gtk_css_parser_error_value (parser, "Unexpected ligature value");
return FALSE;
}
if (parsed_ligature != ligatures)
parsed_numeric = _gtk_css_font_variant_numeric_try_parse_one (parser, numeric);
if (parsed_numeric == 0 && numeric != 0)
{
- _gtk_css_parser_error (parser, "Invalid combination of numeric values");
+ gtk_css_parser_error_value (parser, "Invalid combination of numeric values");
return FALSE;
}
if (parsed_numeric == GTK_CSS_FONT_VARIANT_NUMERIC_NORMAL)
{
- _gtk_css_parser_error (parser, "Unexpected numeric value");
+ gtk_css_parser_error_value (parser, "Unexpected numeric value");
return FALSE;
}
if (parsed_numeric != numeric)
parsed_east_asian = _gtk_css_font_variant_east_asian_try_parse_one (parser, east_asian);
if (parsed_east_asian == 0 && east_asian != 0)
{
- _gtk_css_parser_error (parser, "Invalid combination of east asian values");
+ gtk_css_parser_error_value (parser, "Invalid combination of east asian values");
return FALSE;
}
if (parsed_east_asian == GTK_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL)
{
- _gtk_css_parser_error (parser, "Unexpected east asian value");
+ gtk_css_parser_error_value (parser, "Unexpected east asian value");
return FALSE;
}
if (parsed_east_asian != east_asian)
{
if (_gtk_css_font_variant_position_value_get (values[1]) == GTK_CSS_FONT_VARIANT_POSITION_NORMAL)
{
- _gtk_css_parser_error (parser, "Unexpected position value");
+ gtk_css_parser_error_value (parser, "Unexpected position value");
return FALSE;
}
goto found;
{
if (_gtk_css_font_variant_caps_value_get (values[2]) == GTK_CSS_FONT_VARIANT_CAPS_NORMAL)
{
- _gtk_css_parser_error (parser, "Unexpected caps value");
+ gtk_css_parser_error_value (parser, "Unexpected caps value");
return FALSE;
}
goto found;
{
if (_gtk_css_font_variant_alternate_value_get (values[4]) == GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL)
{
- _gtk_css_parser_error (parser, "Unexpected alternate value");
+ gtk_css_parser_error_value (parser, "Unexpected alternate value");
return FALSE;
}
goto found;
}
}
- _gtk_css_parser_error (parser, "Unknown value for property");
+ gtk_css_parser_error_value (parser, "Unknown value for property");
return FALSE;
found:
values[0] = _gtk_css_font_variant_ligature_value_new (ligatures);
if (values[0] == NULL)
{
- _gtk_css_parser_error (parser, "Invalid combination of ligature values");
+ gtk_css_parser_error_value (parser, "Invalid combination of ligature values");
return FALSE;
}
}
values[3] = _gtk_css_font_variant_numeric_value_new (numeric);
if (values[3] == NULL)
{
- _gtk_css_parser_error (parser, "Invalid combination of numeric values");
+ gtk_css_parser_error_value (parser, "Invalid combination of numeric values");
return FALSE;
}
}
values[5] = _gtk_css_font_variant_east_asian_value_new (east_asian);
if (values[5] == NULL)
{
- _gtk_css_parser_error (parser, "Invalid combination of east asian values");
+ gtk_css_parser_error_value (parser, "Invalid combination of east asian values");
return FALSE;
}
}
GtkCssValue **values,
GtkCssParser *parser)
{
- _gtk_css_parser_error (parser, "The 'all' property can only be set to 'initial', 'inherit' or 'unset'");
+ gtk_css_parser_error_syntax (parser, "The 'all' property can only be set to 'initial', 'inherit' or 'unset'");
return FALSE;
}
GtkCssValue *value = _gtk_css_font_style_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown font style value");
return value;
}
if (value == NULL)
{
value = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER | GTK_CSS_POSITIVE_ONLY);
-
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
- else if (_gtk_css_number_value_get (value, 100) < 1 ||
- _gtk_css_number_value_get (value, 100) > 1000)
+ return NULL;
+
+ if (_gtk_css_number_value_get (value, 100) < 1 ||
+ _gtk_css_number_value_get (value, 100) > 1000)
{
- _gtk_css_parser_error (parser, "Font weight values must be between 1 and 1000");
+ gtk_css_parser_error_value (parser, "Font weight values must be between 1 and 1000");
g_clear_pointer (&value, gtk_css_value_unref);
}
}
GtkCssValue *value = _gtk_css_font_stretch_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown font stretch value");
return value;
}
GtkCssValue *value = _gtk_css_border_style_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown border style value");
return value;
}
GtkCssValue *value = _gtk_css_area_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown box value");
return value;
}
GtkCssValue *value = _gtk_css_direction_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown direction value");
return value;
}
GtkCssValue *value = _gtk_css_play_state_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown play state value");
return value;
}
GtkCssValue *value = _gtk_css_fill_mode_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown fill mode value");
return value;
}
GtkCssValue *value = _gtk_css_icon_style_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown icon style value");
return value;
}
GtkCssValue *value = _gtk_css_text_decoration_line_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown text decoration line value");
return value;
}
GtkCssValue *value = _gtk_css_text_decoration_style_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown text decoration style value");
return value;
}
GtkCssValue *value = _gtk_css_font_kerning_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown font kerning value");
return value;
}
parsed = _gtk_css_font_variant_ligature_try_parse_one (parser, ligatures);
if (parsed == 0 || parsed == ligatures)
{
- _gtk_css_parser_error (parser, "Not a valid value");
+ gtk_css_parser_error_syntax (parser, "Not a valid value");
return NULL;
}
ligatures = parsed;
value = _gtk_css_font_variant_ligature_value_new (ligatures);
if (value == NULL)
- _gtk_css_parser_error (parser, "Invalid combination of values");
+ gtk_css_parser_error_syntax (parser, "Invalid combination of values");
return value;
}
GtkCssValue *value = _gtk_css_font_variant_position_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown font variant position value");
return value;
}
GtkCssValue *value = _gtk_css_font_variant_caps_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown font variant caps value");
return value;
}
parsed = _gtk_css_font_variant_numeric_try_parse_one (parser, numeric);
if (parsed == 0 || parsed == numeric)
{
- _gtk_css_parser_error (parser, "Not a valid value");
+ gtk_css_parser_error_syntax (parser, "Not a valid value");
return NULL;
}
numeric = parsed;
value = _gtk_css_font_variant_numeric_value_new (numeric);
if (value == NULL)
- _gtk_css_parser_error (parser, "Invalid combination of values");
+ gtk_css_parser_error_syntax (parser, "Invalid combination of values");
return value;
}
GtkCssValue *value = _gtk_css_font_variant_alternate_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "unknown font variant alternate value");
return value;
}
parsed = _gtk_css_font_variant_east_asian_try_parse_one (parser, east_asian);
if (parsed == 0 || parsed == east_asian)
{
- _gtk_css_parser_error (parser, "Not a valid value");
+ gtk_css_parser_error_syntax (parser, "Not a valid value");
return NULL;
}
east_asian = parsed;
value = _gtk_css_font_variant_east_asian_value_new (east_asian);
if (value == NULL)
- _gtk_css_parser_error (parser, "Invalid combination of values");
+ gtk_css_parser_error_syntax (parser, "Invalid combination of values");
return value;
}
if (value == NULL)
{
- _gtk_css_parser_error (parser, "Not a valid value");
+ gtk_css_parser_error_syntax (parser, "Not a valid border repeat value");
return NULL;
}
if (value == NULL)
{
- _gtk_css_parser_error (parser, "Expected an identifier");
+ gtk_css_parser_error_syntax (parser, "Expected an identifier");
return NULL;
}
GtkCssValue *value = _gtk_css_blend_mode_value_try_parse (parser);
if (value == NULL)
- _gtk_css_parser_error (parser, "unknown value for property");
+ gtk_css_parser_error_syntax (parser, "Unknown blend mode value");
return value;
}
if (value == NULL)
{
- _gtk_css_parser_error (parser, "Not a valid value");
+ gtk_css_parser_error_syntax (parser, "Unknown repeat value");
return NULL;
}
if (array->len == 0)
{
- _gtk_css_parser_error (parser, "Expected a transform");
+ gtk_css_parser_error_syntax (parser, "Expected a transform");
goto fail;
}